using System;
using System.Collections.Generic;
using Hematology.Data.Interface;

namespace Hematology.Data
{
	public partial class SiteEvent : IComparable<SiteEvent>, ISimpleData
	{
		private List<FileAttach> _fileAttachements;
		public List<FileAttach> FileAttachements
		{
			get
			{
				_fileAttachements = new List<FileAttach>();
				if (EventId != null)
					_fileAttachements.AddRange(FileAttach.ListByEventId(EventId.Value));

				return _fileAttachements;
			}
		}

		public void Save()
		{
			IsDeleted = false;
			CreateDate = DateTime.Now;
			LastModifiedDate = DateTime.Now;

			Insert();
		}

		public void UpdateInstance()
		{
			LastModifiedDate = DateTime.Now;
			
			Update();
		}

		public void MarkAsDeleted()
		{
			IsDeleted = true;

			Update();
		}

		public static List<SiteEvent> ListAllEvents(int? contentType, bool bIsOnlyVisible)
		{
			return Search(null, null, null, null, contentType, null, null, null, false, bIsOnlyVisible ? true : (bool?) null, null, null);
		}

		public int CompareTo(SiteEvent other)
		{
			return Title.CompareTo(other.Title);
		}
	}
}

